package com.hxkj.dao.impl;

import com.hxkj.dao.UserSiteDao;
import com.hxkj.domain.po.Site;
import com.hxkj.mapper.SiteMapper;
import com.hxkj.mapper.UserSiteMapper;
import com.hxkj.domain.po.UserSite;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;


/**
* 数据操作实现
*
* @author: chenwei
* @version: 1.0
* @datetime: 2018-05-21 17:59:26
*
*/
@Service("userSiteDao")
public class UserSiteDaoImpl implements UserSiteDao {

    @Resource
    private UserSiteMapper userSiteMapper;

    @Resource
    private SiteMapper siteMapper;

    @Override
    public UserSite get(Long id) {
        return userSiteMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<UserSite> get(UserSite userSite) {
        return userSiteMapper.select(userSite);
    }

    @Override
    public int delete(Long id) {
        return userSiteMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteUserSiteBySiteId(Long siteId) {
        return userSiteMapper.deleteUserSiteBySiteId(siteId);
    }

    @Override
    public int delete(UserSite userSite) {
        return userSiteMapper.delete(userSite);
    }

    @Override
    public int save(UserSite userSite) {
        //添加当前时间戳
        userSite.setCreateTime(System.currentTimeMillis());
        return userSiteMapper.insert(userSite);
    }

    @Override
    public int update(UserSite userSite) {
        return userSiteMapper.update(userSite);
    }

    @Override
    public List<Site> getAassignedSite(Long uid) {
        return siteMapper.getAassignedSite(uid);
    }

    /**
    * @author Mr.zheng
    * @Description deleteUserSite 根据用户ID和站点ID执行删除操作
    * @Date 12:02 2018/6/1
    * @Param [userSite]
    * @return void
    **/
    @Override
    public int deleteUserSite(UserSite userSite) {
        return userSiteMapper.deleteUserSite(userSite);
    }
}
